using System.Collections.Generic;
using UnityEngine;

public class PlayerListLayer : MonoBehaviour
{
	public UITable table;

	public GameObject playerListItemPrefab;

	protected List<PlayerListItem> items = new List<PlayerListItem>();

	public void OnEnable()
	{
		List<PlayerDB.TournamentPlayer> players = PlayerDB.instance.players;
		int num = 0;
		foreach (PlayerDB.TournamentPlayer item in players)
		{
			PlayerListItem playerListItem = null;
			if (num >= items.Count)
			{
				items.Add(NGUITools.AddChild(table.gameObject, playerListItemPrefab).GetComponent<PlayerListItem>());
			}
			playerListItem = items[num];
			playerListItem.gameObject.name = GGFormat.IndexName(num);
			playerListItem.gameObject.SetActive(true);
			playerListItem.Init(item, num);
			num++;
		}
		table.Reposition();
	}
}
